fix(vue-table): render nothing for an empty string cell - #6590
Open
Yash121l wants to merge 1 commit into
Open
Conversation
flexRender returns the value it is given for primitives, so a cell or header whose value is an empty string produces an empty text vnode. Vue's server renderer emits nothing for it, the client creates a text node, and hydration reports a children mismatch inside the cell. Return null for an empty string, matching how flexRender already treats null and undefined, so server and client agree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Fixes #6077.
flexRenderpasses primitives straight through, so a cell or header whose value is an empty string produces an empty text vnode. Vue's server renderer emits nothing for it while the client creates a text node, so hydration reportsHydration children mismatchinside the<td>.flexRendernow returnsnullfor an empty string, in both the direct path and the path that runs a render function, which is how it already treatsnullandundefined. React'sflexRenderdoes not have this problem because React renders an empty string as nothing on both the server and the client, so this brings the Vue adapter in line with it.The new test at
packages/vue-table/tests/unit/flexRenderHydration.test.tsrenders a one-cell table withrenderToString, hydrates a client app into that markup and asserts no hydration warning is logged. Onmainit fails with[Vue warn]: Hydration children mismatch on.@tanstack/vue-tablepassestest:lib,test:types,test:eslint,test:buildandbuild.pnpm test:prpasses for all 41 affected projects, and the affected Vue example e2e suites pass.✅ Checklist
pnpm testandpnpm test:e2e, or these tests do not apply to this pull request.🚀 Release Impact